package com.example.zhu.controller;


import com.example.zhu.dto.ManageDTO;
import com.example.zhu.entity.Manage;
import com.example.zhu.result.Result;
import com.example.zhu.service.ManageService;
import com.example.zhu.vo.ManageVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin
@RequestMapping("/admin/manage")
public class ManageController {

    @Autowired
    private ManageService manageService;

    /**
     * 新增区域划分 done
     * @param manageDTO
     * @return
     */
    @PostMapping("/insert")
    public Result insert(@RequestBody ManageDTO manageDTO){
        return manageService.insert(manageDTO);
    }

    /**
     * 查询编辑信息 done
     * @param id
     * @return
     */
    @GetMapping("/selectEditInfo")
    public Result<Manage> selectEditInfo(@RequestParam Integer id){
        Manage manageVO = manageService.selectEditInfo(id);
        return Result.success(manageVO);
    }

    /**
     * 编辑信息 done
     * @param manageDTO
     * @return
     */
    @PutMapping("/update")
    public Result update(@RequestBody ManageDTO manageDTO){
        return manageService.update(manageDTO);
    }

    /**
     * 查询
     * @return
     */
    @GetMapping("/selectAll")
    public Result<List<ManageVO>> selectAll(){
        List<ManageVO> list = manageService.selectAll();
        return Result.success(list);
    }



}
